//
//  RootViewController.m
//  爱寻找
//
//  Created by qianfeng0 on 16/6/23.
//  Copyright © 2016年 王超. All rights reserved.
//

#import "RootViewController.h"
#import "TabBarVC.h"
#import "AppDelegate.h"

//屏幕的宽 高
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height

@interface RootViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
}

#pragma mark -初始化UI
- (void)initUI {
    
    self.scrollView.contentSize = CGSizeMake(ScreenWidth * 3, ScreenHeight);
    
    NSArray * imageArray = @[@"welcome1", @"welcome2", @"welcome3"];
    for (int i = 0; i < imageArray.count; i++) {
        
        UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * ScreenWidth, 0, ScreenWidth, ScreenHeight)];
        imageView.image = [UIImage imageNamed:imageArray[i]];
        
        [self.scrollView addSubview:imageView];
        
        if (i == imageArray.count - 1) {
            
            UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goMain)];
            [imageView addGestureRecognizer:tap];
            
            //打开交互
            imageView.userInteractionEnabled = YES;
        }
    }
}

- (void)goMain {
    
    //无连线跳转
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    TabBarVC * tabVc = [storyboard instantiateViewControllerWithIdentifier:@"TabBarVC"];
    
    //切换rootViewcontroller
    AppDelegate * app = [UIApplication sharedApplication].delegate;
    app.window.rootViewController = tabVc;
}

@end
